package com.wwh.tx;

import com.wwh.tx.dao.GoodsDAO;
import com.wwh.tx.service.GoodsService;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Albert
 * @date 2024/8/29-11:00
 * @describe
 */
public class TxTest {
    @Test
    public void testGoodsDAO(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("tx.xml");
        GoodsDAO goodsDAO = ioc.getBean(GoodsDAO.class);

        //System.out.println(goodsDAO.queryPriceById(1));
        //System.out.println(goodsDAO.queryPriceById(2));
        //System.out.println(goodsDAO.queryPriceById(3));

        //goodsDAO.updateBalance(1, 1f);

        goodsDAO.updateAmount(1, 1);
    }

    @Test
    public void testGoodsService(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("tx.xml");
        GoodsService goodsService = ioc.getBean(GoodsService.class);

        goodsService.buyGoods(1, 1, 1);
    }
}
